package com.dinetech.dao;

import java.util.ArrayList;

import com.dinetech.ejecutor.R;
import com.dinetech.entidades.Eventos;
import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class EventoAdapter extends BaseAdapter{
	
	protected Activity activity;
	protected ArrayList<Eventos> items;
	
	public EventoAdapter(Activity activity,ArrayList<Eventos> items){
		
		
		
	this.activity = activity;
	this.items = items;
	

	
	
}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return items.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return items.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		
		return items.get(position).getId();
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View vi = convertView;
		
		if(convertView == null) {
        	LayoutInflater inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        	vi = inflater.inflate(R.layout.listview_selected_item, null);
        }
            
        Eventos item = items.get(position);        
        
        TextView txtdescripcion = (TextView) vi.findViewById(R.id.txtDescripcionEvento);
        txtdescripcion.setText(item.getNombre());
        return vi;
	}

	@Override
	public int getItemViewType(int position) {
		// TODO Auto-generated method stub
		return Integer.parseInt(items.get(position).getCodEvento().toString());
	}
	

}
